#ifndef XMLCONFIG_H
#define XMLCONFIG_H

#include <string>
#include <vector>
#include "tinyxml.h"

#ifdef _WIN32
class TiXmlNodeEx : public TiXmlNode
{
public:
    TiXmlNodeEx() : TiXmlNode(TiXmlNode::TINYXML_DOCUMENT) {};
    virtual ~TiXmlNodeEx() {};
    const char * GetEncoding(const char * file);
    const char* ParseData(const char * data);

    const char* Parse(const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING)
    {
        return NULL;
    }

    void Print(FILE* cfile, int depth = 0) const
    {
    }

    virtual bool Accept(TiXmlVisitor* content) const
    {
        return false;
    }

    TiXmlNode* Clone() const
    {
        return 0;
    }
};
#endif

class XmlConfig
{
public:
    bool Open(const char *fileName);
    const char* Get(const char *element, const char *attribute, const char *defaultValue);
    int GetIntValue(const char *element, const char *attribute, int defaultValue);
    double GetDoubleValue(const char *element, const char *attribute, double defaultValue);
    bool Set(const char *elementName, const char *attribute, const char *value);
    bool Save(const char *fileName);
    const char* GetEncoding();

private:
    const char* file = "";
    TiXmlDocument document;
    TiXmlElement* rootElem;
};

#endif
